package org.example.factory.before;

/**
 * @Author KEKE
 * @Date 2024/7/1 9:30
 * @Description 咖啡店
 * @Version 1.0
 */
public class CoffeeStore {
    public  Coffee orderCoffee(String type){
        //声明coffee类型的变量，根据不同类型创建不同的coffee子类对象
        Coffee coffee = null;
        if("american".equals(type)){
            coffee = new AmericanCoffee();
        }else if("latter".equals(type)){
            coffee = new LatterCoffee();
        }else{
            throw new RuntimeException("所点的咖啡没有此类型");
        }
        //加糖，加奶
        coffee.addmilk();
        coffee.addsugar();
        return coffee;
    }
}
